package com.calvin.study.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import cloud.alibaba.study.entity.storage.Storage;

@Repository
public interface StorageMapper extends BaseMapper<Storage> {
	
	 /**
     * 扣减库存
     */
	@Select("update t_storage set used=#{count}, residue = (total-#{count}) where product_id = #{productId}")
    void decreaseStorage(@Param("productId") Long productId, @Param("count") Integer count);

}
